﻿Public Class RenameAction
    
    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="scriptGroup"></param>
    ''' <returns></returns>
    Public Shared Function CanExecute(Byval scriptGroup as ScriptGroup) as Boolean
        return scriptGroup IsNot Nothing
    End Function

    Public Shared Sub Execute(Byval scriptGroup as ScriptGroup) 

        If scriptGroup Is Nothing Then
            Throw New ArgumentNullException("scriptGroup")
        End If

        Dim dialog As New TextDialog("New Group Name", "Rename Script Group", True, scriptGroup.Name)

        'Show the dialog
        Dim result As Boolean? = dialog.ShowDialog()

        'Check to see if the user accepted this
        If result.HasValue AndAlso result.Value Then

            'Update the name of the group
            scriptGroup.Name = dialog.UserText
        End If

    End Sub
    

End Class
